package com.serli.sample.data.runner.view;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

import com.serli.sample.data.runner.domain.Trip;

public class TripDetail extends Panel {

	private static final long serialVersionUID = 1L;

	public TripDetail(String id, IModel model) {
		super(id, model);
		
		if(model.getObject() != null && model.getObject() instanceof Trip) {
			add(new Label("tripDetailName", new PropertyModel(model.getObject(), "name")));
			add(new Label("tripDetailDistance", new PropertyModel(model.getObject(), "distance")));
			add(new Label("tripDetailNote", new PropertyModel(model.getObject(), "note")));
		} else {
			add(new Label("tripDetailName", "N/A"));
			add(new Label("tripDetailDistance", "N/A"));
			add(new Label("tripDetailNote", "N/A"));
		}
	}
}
